package com.artpri.dao.impl;

import java.util.List;

import com.artpri.dao.CollectGoodsDao;
import com.artpri.model.CollectGoods;

/**
 * 
 * @author ZhangSi
 *
 */
public class CollectGoodsDaoImpl extends HibernateDaoImpl<CollectGoods>
		implements CollectGoodsDao {

	@Override
	public boolean checkCollectGoodsExists(int userNum, Integer goodsNum) {
		int i = findCount("select count(*) from CollectGoods c where c.userNum=?0 and c.goodsNum=?1", new Object[]{userNum, goodsNum});
		return i == 0 ? false : true;
	}

	@Override
	public void delete(List<Integer> ids) {
		Object[][] params = new Object[ids.size()][1];
		
		for(int i = 0; i < ids.size(); i++) {
			Object[] param = new Object[]{ids.get(i)};
			params[i] = param;
		}
		
		updateBatch("delete from collect_goods where collect_id=?", params);
	}


}
